package tech.aister.mapper;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import teach.aistar.pojo.User;
import teach.aistar.pojo.UserVo;

/**
 * 本来用来演示: UserMapper的单元测试
 *
 * @author success
 * @date 2025/2/26 11:05:14
 */
@SpringBootTest
public class UserMapperTest {
    @Autowired
    private UserMapper userMapper;

    //单击选中testFindAll单词 -> 右击-Run
    @Test
    public void testFindAll(){
        userMapper.findAll().forEach(u-> System.out.println(u));
    }

    @Test
    public void testGetByEmail(){
        User user = userMapper.getByEmail("2422368325@qq.com");
        System.out.println(user);
    }

    @Test
    public void testDelById(){
        int count = userMapper.delById(3);
        System.out.println("成功删除了"+count+"行!");
    }

    @Test
    public void testFindByUsernameAndPassword(){
        User user = userMapper.findByUsernameAndPassword("admin","123456");
        System.out.println(user);
    }

    @Test
    public void testGetByUsernameAndPassword(){
        //定义一个第三方对象
        UserVo userVo = new UserVo("admin","123456");
        User user = userMapper.getByUsernameAndPassword(userVo);
        System.out.println(user);
    }
}